package com.csun.cmny.provider.controller;

import com.csun.cmny.core.support.BaseController;
import com.csun.cmny.provider.dto.*;
//import com.csun.cmny.provider.model.dto.doctor.HuaLongBloodPressureDownDto;
//import com.csun.cmny.provider.model.vo.doctor.HuaLongBloodPressureRecordVo;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.ChongmingDoctorWorkService;
//import com.csun.cmny.provider.utils.JxlExcelUtils;
//import com.csun.cmny.provider.vo.DoctorWorkMedicalAdviceDownVo;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import com.github.pagehelper.PageInfo;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;


/**
 * @Auther: ZNR
 * @Date: 2020-10-20
 * @Description: 上海华隆崇明医生工作记录管理controller
 */

@RestController
@RequestMapping(value = "/chongming", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class OmcChongmingDoctorWorkController extends BaseController {
    @Resource
    private ChongmingDoctorWorkService chongmingDoctorWorkService;
    @Resource
    private CmnyMessageSource cmnyMessageSource;

    /**
     * 查询老人血压记录
     *
     * @return
     */
    @RequestMapping(value = "/selectBloodPressure", method = RequestMethod.POST)
    public Wrapper queryListWithPage(@RequestBody DoctorWorkBloodPressureDto doctorWorkBloodPressureDto) {

        //doctorWorkBloodPressureDto.setOperatorId(getLoginAuthDto().getUserId());
        PageInfo pageInfo = chongmingDoctorWorkService.selectBloodPressure(doctorWorkBloodPressureDto);

        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null), pageInfo);
    }

    /**
     * 上传血压记录数据
     *
     * @return
     */
    @RequestMapping(value = "/upBloodPressure", method = RequestMethod.POST)
    public Wrapper upBloodPressure(@RequestBody DoctorWorkUpBloodPressureDto doctorWorkUpBloodPressureDto){
        Integer result = chongmingDoctorWorkService.upBloodPressure(doctorWorkUpBloodPressureDto);
        if(result < 1) {
            return WrapMapper.wrap(Wrapper.ERROR_CODE, cmnyMessageSource.getMessage("operation.failed", null));
        }
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),result);
    }

    /**
     * 查询老人体温记录
     *
     * @return
     */
    @RequestMapping(value = "/selectTemperature", method = RequestMethod.POST)
    public Wrapper queryListTemperatureWithPage(@RequestBody DoctorWorkTemperatureDto doctorWorkTemperatureDto){

        //doctorWorkTemperatureDto.setDoctorId(getLoginAuthDto().getUserId());
        PageInfo pageInfo = chongmingDoctorWorkService.selectTemperature(doctorWorkTemperatureDto);

        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null), pageInfo);

    }

    /**
     * 上传体温记录数据
     *
     * @return
     */
    @RequestMapping(value = "/upTemperature", method = RequestMethod.POST)
    public Wrapper upTemperature(@RequestBody DoctorWorkUpTemperatureDto doctorWorkUpBloodPressureDto){
        Integer result = chongmingDoctorWorkService.upTemperature(doctorWorkUpBloodPressureDto);
        if(result < 1) {
            return WrapMapper.wrap(Wrapper.ERROR_CODE, cmnyMessageSource.getMessage("operation.failed", null));
        }
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),result);
    }

    /**
     * 查询长期医嘱单
     *
     * @return
     */

    @RequestMapping(value = "/selectMedicalAdvice")
    public Wrapper queryListMedicalAdviceWithPage(@RequestBody DoctorWorkMedicalAdviceDto doctorWorkMedicalAdviceDto){

        //doctorWorkMedicalAdviceDto.setDoctorId(getLoginAuthDto().getUserId());
        PageInfo pageInfo = chongmingDoctorWorkService.selectMedicalAdvice(doctorWorkMedicalAdviceDto);

        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null), pageInfo);
    }

    /**
     * 添加长期医嘱单
     *
     * @return
     */
    @RequestMapping(value = "/addMedicalAdvice", method = RequestMethod.POST)
    public Wrapper addMedicalAdvice(@RequestBody DoctorWorkAddMedicalAdviceDto doctorWorkAddMedicalAdviceDto){
        Integer result = chongmingDoctorWorkService.addMedicalAdvice(doctorWorkAddMedicalAdviceDto);
        if(result < 1){
            return  WrapMapper.wrap(Wrapper.ERROR_CODE, cmnyMessageSource.getMessage("operation.failed", null));
        }
        return  WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null),result);
    }

    /**
     * 停止长期医嘱
     *
     * @return
     */
    @RequestMapping(value = "/stopMedicalAdvice", method = RequestMethod.POST)
    public Wrapper stopMedicalAdvice(@RequestBody DoctorWorkStopMedicalAdviceDto doctorWorkStopMedicalAdviceDto){
        Integer result = chongmingDoctorWorkService.stopMedicalAdvice(doctorWorkStopMedicalAdviceDto);
        if (result < 1){
            return WrapMapper.wrap(Wrapper.ERROR_CODE, cmnyMessageSource.getMessage("operation.failed", null));
        }
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null),result);
    }

    /**
     * 修改长期医嘱
     *
     * @return
     */
    @RequestMapping(value = "/modifyMedicalAdvice", method = RequestMethod.POST)
    public Wrapper modifyMedicalAdvice(@RequestBody DoctorWorkModifyMedicalAdviceDto doctorWorkModifyMedicalAdviceDto){
        Integer result = chongmingDoctorWorkService.modifyMedicalAdvice(doctorWorkModifyMedicalAdviceDto);
        if(result < 1){
            return WrapMapper.wrap(Wrapper.ERROR_CODE, cmnyMessageSource.getMessage("operation.failed", null));
        }
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null),result);
    }

    /**
     * 删除长期医嘱
     *
     * @reture
     */
    @RequestMapping(value = "/deleteMedicalAdvice", method = RequestMethod.POST)
    public Wrapper deleteMedicalAdvice(@RequestBody DoctorWorkModifyMedicalAdviceDto doctorWorkModifyMedicalAdviceDto){
        Integer result = chongmingDoctorWorkService.deleteMedicalAdvice(doctorWorkModifyMedicalAdviceDto);
        if (result < 1){
            return WrapMapper.wrap(Wrapper.ERROR_CODE, cmnyMessageSource.getMessage("operation.failed", null));
        }
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null),result);
    }

    /**
     * 查询病程记录
     *
     * @return
     */
    @RequestMapping(value = "/selectMedicalRecord")
    public Wrapper queryListMedicalRecordWithPage(@RequestBody DoctorWorkMedicalRecordDto doctorWorkMedicalRecordDto){

        PageInfo pageInfo = chongmingDoctorWorkService.selectMedicalRecord(doctorWorkMedicalRecordDto);

        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null), pageInfo);
    }

    //添加病程记录
    @RequestMapping(value = "/addMedicalRecord", method = RequestMethod.POST)
    public Wrapper addMedicalRecord(@RequestBody DoctorWorkAddMedicalRecordDto doctorWorkAddMedicalRecordDto){
        Integer result = chongmingDoctorWorkService.addMedicalRecord(doctorWorkAddMedicalRecordDto);
        if(result < 1){
            return WrapMapper.wrap(Wrapper.ERROR_CODE, cmnyMessageSource.getMessage("operation.failed", null));
        }
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null),result);
    }

    //修改病程记录
    @RequestMapping(value = "/modifyMedicalRecord", method = RequestMethod.POST)
    public Wrapper modifyMedicalRecord(@RequestBody DoctorWorkModifyMedicalRecordDto doctorWorkModifyMedicalRecordDto){
        Integer result = chongmingDoctorWorkService.modifyMedicalRecord(doctorWorkModifyMedicalRecordDto);
        if(result < 1){
            return WrapMapper.wrap(Wrapper.ERROR_CODE, cmnyMessageSource.getMessage("operation.failed", null));
        }
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null),result);
    }

    //删除病程记录
    @RequestMapping(value = "/deleteMedicalRecord", method = RequestMethod.POST)
    public Wrapper deleteMedicalRecord(@RequestBody DoctorWorkModifyMedicalRecordDto doctorWorkModifyMedicalRecordDto){
        Integer result = chongmingDoctorWorkService.deleteMedicalRecord(doctorWorkModifyMedicalRecordDto);
        if (result < 1){
            return WrapMapper.wrap(Wrapper.ERROR_CODE, cmnyMessageSource.getMessage("operation.failed", null));
        }
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource.getMessage("operation.success", null),result);
    }






}


